$(function(){
	
	
	$("#btn-upload").click(function(){
		$("#block-upload").removeClass("hidden");
		$("#btn-upload-cancel").removeClass("hidden");
	})
	
	$("#btn-upload-cancel").click(function(){
		$("#block-upload").addClass("hidden");
		$("#btn-upload-cancel").addClass("hidden");
		
	})
	
	
	
	
	
	
	
	
	

})

	var BaseTableDatatables = function() {
	    // Init full DataTable, for more examples you can check out https://www.datatables.net/
	    var initDataTableFull = function() {
	        jQuery('#example').dataTable({
	        	 "processing": true,
	             "serverSide": true,
	             "bAutoWidth": true,
	             "autoWidth": false,
	             "destroy" : true,
	             "ajax": "file/getUploadFileInfPageInate",
	            //columnDefs: [ { orderable: false, targets: [ 4 ] } ],
	            "pageLength": 10,
	            "lengthMenu": [[5, 10, 15, 20], [5, 10, 15, 20]],
	            "fnDrawCallback"    : function(){
                  　　this.api().column(0).nodes().each(function(cell, i) {
                  　　　　cell.innerHTML =  i + 1;
                  　　});
                  },
	            "columns" : 
	            	[//对接收到的json格式数据进行处理，data为json中对应的key
	                       /*  {"data":"Note_person" , "bVisible": false,"bSearchable": false},*/
			            	 { "data": null , "sClass": "text-center"},
	            	 		{ "data": "Id" , "sClass": "text-center"},
            	 			{"data":"File_Show_Name", "sClass": "text-center"},
            	 			{"data":"Note_persion", "sClass": "text-center" },
	            	 		{"data":"fdirectory", "sClass": "text-center" },
	                        {"data": "" ,"sClass": "text-center",
	                        	 "render": function ( data, type, full, meta ) {
	                        		 var html = " <div class='btn-group text-center' style='text-center;width:100%;margin:0 auto'>";
	                        		 html+="<div>";
	                        		 html+= "<button class='btn btn-sm btn-primary btn-default push-5-r ' type='button'   onclick='openEditModal( \""+full.Id+"\" ,\""+full.fdirectory +"\", \""+full.File_Name+"\");'  title=' data-original-title='Edit Client'><i class='fa fa-pencil'></i></button>";
	                        		 html+="<button class='btn btn-sm btn-danger btn-default push-5-r ' type='button' data-toggle='tooltip' title=' data-original-title='Remove Client'><i class='fa fa-times'></i></button>";
	                        		 html+="</div>";
	                        		 html+="</div>";
	                                 return html;
	                             }
	                         },

	                     ],
	                     "oLanguage" : { // 国际化配置
	                         "sProcessing" : "正在获取数据，请稍后...",
	                         "sLengthMenu" : "显示 _MENU_ 条",
	                         "sZeroRecords" : "没有找到数据",
	                         "sInfo" : "从 _START_ 到  _END_ 条记录 总记录数为 _TOTAL_ 条",
	                         "sInfoEmpty" : "记录数为0",
	                         "sInfoFiltered" : "(全部记录数 _MAX_ 条)",
	                         "sInfoPostFix" : "",
	                         "sSearch" : "查询",
	                         "sUrl" : "",
	                         "oPaginate" : {
	                             "sFirst" : "第一页",
	                             "sPrevious" : "上一页",
	                             "sNext" : "下一页",
	                             "sLast" : "最后一页"
	                         }
	                     }
	        });
	    };

	    // Init full extra DataTable, for more examples you can check out https://www.datatables.net/
	/*    var initDataTableFullPagination = function() {
	        jQuery('.js-dataTable-full-pagination').dataTable({
	            pagingType: "full_numbers",
	            columnDefs: [ { orderable: false, targets: [ 4 ] } ],
	            pageLength: 10,
	            lengthMenu: [[5, 10, 15, 20], [5, 10, 15, 20]]
	        });
	    };*/

	    // Init simple DataTable, for more examples you can check out https://www.datatables.net/
	/*    var initDataTableSimple = function() {
	        jQuery('.js-dataTable-simple').dataTable({
	            columnDefs: [ { orderable: false, targets: [ 4 ] } ],
	            pageLength: 10,
	            lengthMenu: [[5, 10, 15, 20], [5, 10, 15, 20]],
	            searching: false,
	            oLanguage: {
	                sLengthMenu: ""
	            },
	            dom:
	                "<'row'<'col-sm-12'tr>>" +
	                "<'row'<'col-sm-6'i><'col-sm-6'p>>"
	        });
	    };*/

	    // DataTables Bootstrap integration
	    var bsDataTables = function() {
	        var $DataTable = jQuery.fn.dataTable;

	        // Set the defaults for DataTables init
	        jQuery.extend( true, $DataTable.defaults, {
	            dom:
	                "<'row'<'col-sm-6'l><'col-sm-6'f>>" +
	                "<'row'<'col-sm-12'tr>>" +
	                "<'row'<'col-sm-6'i><'col-sm-6'p>>",
	            renderer: 'bootstrap',
	            oLanguage: {
	                sLengthMenu: "_MENU_",
	                sInfo: "Showing <strong>_START_</strong>-<strong>_END_</strong> of <strong>_TOTAL_</strong>",
	                oPaginate: {
	                    sPrevious: '<i class="fa fa-angle-left"></i>',
	                    sNext: '<i class="fa fa-angle-right"></i>'
	                }
	            }
	        });

	        // Default class modification
	        jQuery.extend($DataTable.ext.classes, {
	            sWrapper: "dataTables_wrapper form-inline dt-bootstrap",
	            sFilterInput: "form-control",
	            sLengthSelect: "form-control"
	        });

	        // Bootstrap paging button renderer
	        $DataTable.ext.renderer.pageButton.bootstrap = function (settings, host, idx, buttons, page, pages) {
	            var api     = new $DataTable.Api(settings);
	            var classes = settings.oClasses;
	            var lang    = settings.oLanguage.oPaginate;
	            var btnDisplay, btnClass;

	            var attach = function (container, buttons) {
	                var i, ien, node, button;
	                var clickHandler = function (e) {
	                    e.preventDefault();
	                    if (!jQuery(e.currentTarget).hasClass('disabled')) {
	                        api.page(e.data.action).draw(false);
	                    }
	                };

	                for (i = 0, ien = buttons.length; i < ien; i++) {
	                    button = buttons[i];

	                    if (jQuery.isArray(button)) {
	                        attach(container, button);
	                    }
	                    else {
	                        btnDisplay = '';
	                        btnClass = '';

	                        switch (button) {
	                            case 'ellipsis':
	                                btnDisplay = '&hellip;';
	                                btnClass = 'disabled';
	                                break;

	                            case 'first':
	                                btnDisplay = lang.sFirst;
	                                btnClass = button + (page > 0 ? '' : ' disabled');
	                                break;

	                            case 'previous':
	                                btnDisplay = lang.sPrevious;
	                                btnClass = button + (page > 0 ? '' : ' disabled');
	                                break;

	                            case 'next':
	                                btnDisplay = lang.sNext;
	                                btnClass = button + (page < pages - 1 ? '' : ' disabled');
	                                break;

	                            case 'last':
	                                btnDisplay = lang.sLast;
	                                btnClass = button + (page < pages - 1 ? '' : ' disabled');
	                                break;

	                            default:
	                                btnDisplay = button + 1;
	                                btnClass = page === button ?
	                                        'active' : '';
	                                break;
	                        }

	                        if (btnDisplay) {
	                            node = jQuery('<li>', {
	                                'class': classes.sPageButton + ' ' + btnClass,
	                                'aria-controls': settings.sTableId,
	                                'tabindex': settings.iTabIndex,
	                                'id': idx === 0 && typeof button === 'string' ?
	                                        settings.sTableId + '_' + button :
	                                        null
	                            })
	                            .append(jQuery('<a>', {
	                                    'href': '#'
	                                })
	                                .html(btnDisplay)
	                            )
	                            .appendTo(container);

	                            settings.oApi._fnBindAction(
	                                node, {action: button}, clickHandler
	                            );
	                        }
	                    }
	                }
	            };

	            attach(
	                jQuery(host).empty().html('<ul class="pagination"/>').children('ul'),
	                buttons
	            );
	        };

	        // TableTools Bootstrap compatibility - Required TableTools 2.1+
	        if ($DataTable.TableTools) {
	            // Set the classes that TableTools uses to something suitable for Bootstrap
	            jQuery.extend(true, $DataTable.TableTools.classes, {
	                "container": "DTTT btn-group",
	                "buttons": {
	                    "normal": "btn btn-default",
	                    "disabled": "disabled"
	                },
	                "collection": {
	                    "container": "DTTT_dropdown dropdown-menu",
	                    "buttons": {
	                        "normal": "",
	                        "disabled": "disabled"
	                    }
	                },
	                "print": {
	                    "info": "DTTT_print_info"
	                },
	                "select": {
	                    "row": "active"
	                }
	            });

	            // Have the collection use a bootstrap compatible drop down
	            jQuery.extend(true, $DataTable.TableTools.DEFAULTS.oTags, {
	                "collection": {
	                    "container": "ul",
	                    "button": "li",
	                    "liner": "a"
	                }
	            });
	        }
	    };

	    return {
	        init: function() {
	            // Init Datatables
	            bsDataTables();
//	            initDataTableSimple();
	            initDataTableFull();
//	            initDataTableFullPagination();
	        }
	    };
	}();



